import request from '@/utils/request'

const user_url = '/sys/user'

// 获取员工的简单列表
export const getEmployeeSimpleAPI = () =>
  request({
    url: `${user_url}/simple`
  })

// 获取员工列表
export const getEmployeeListAPI = params =>
  request({
    url: user_url,
    params
  })

// 删除员工
export const delEmployeeAPI = id =>
  request({
    url: `${user_url}/${id}`,
    method: 'delete'
  })

// 新增员工
export const addEmployeeAPI = data =>
  request({ method: 'post', url: user_url, data })

// 批量导入员工
export const exportEmployeeAPI = data =>
  request({ method: 'post', url: `${user_url}/batch`, data })

// 获取员工基本信息
export const getEmployeeDetailAPI = id => request({ url: `${user_url}/${id}` })

// 提交保存员工基本信息
export const editEmployeeDetailAPI = (id, data) =>
  request({ url: `${user_url}/${id}`, data })

//  读取用户详情的基础信息
export const getPersonalDetailAPI = id =>
  request({
    url: `/employees/${id}/personalInfo`
  })

//   更新用户详情的基础信息
export const updatePersonalAPI = (id, data) =>
  request({
    url: `/employees/${id}/personalInfo`,
    method: 'put',
    data
  })

//  获取用户的岗位信息
export const getJobDetailAPI = id =>
  request({
    url: `/employees/${id}/jobs`
  })

//  保存岗位信息
export const updateJobAPI = data =>
  request({
    url: `/employees/${data.userId}/jobs`,
    method: 'put',
    data
  })
